/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package swingDemoEvent;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
class JTextFieldCaretDemo extends JFrame 
{
    String strMessage="Hello World";
    JTextField txt1;
    JTextField txt2;
    public JTextFieldCaretDemo(){
        txt1=new JTextField(strMessage,15);
        txt2=new JTextField(strMessage,15);
        setLayout(new FlowLayout());
        txt1.addCaretListener(new CaretListener() {
            public void caretUpdate(CaretEvent e) {
                txt2.setText(txt1.getText());  
            }
        });
        add(txt1);
        add(txt2);
        pack();
        setVisible(true);
    }
    public static void main(String args[]){
        new JTextFieldCaretDemo();
    }
}
